package com.yayohos.locationmanager;

import com.yayohos.locationmanager.base.slice.LocationBaseAbilitySlice;
import com.yayohos.locationmanager.base.slice.SampleSlicePageSlice;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;

/**
 * 在AbilitySlice中定位.
 * 需要引入权限回调
 */
public class SampleSlicePage extends Ability {
    private LocationBaseAbilitySlice.AbilitySliceCallBack abilitySliceCallBack;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setMainRoute(SampleSlicePageSlice.class.getName());
    }

    public void setAbilitySliceCallBack(LocationBaseAbilitySlice.AbilitySliceCallBack abilitySliceCallBack){
        this.abilitySliceCallBack = abilitySliceCallBack;
    }

    @Override
    public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsFromUserResult(requestCode, permissions, grantResults);
        if (abilitySliceCallBack==null){
            return;
        }
        abilitySliceCallBack.onRequestPermissionsFromUserResult(requestCode,permissions,grantResults);
    }

    @Override
    protected void onStop() {
        super.onStop();
        abilitySliceCallBack = null;
    }
}
